package problem24;

//24.两两交换链表中的节点
//https://leetcode.cn/problems/swap-nodes-in-pairs/description/

class Solution {
    public ListNode swapPairs(ListNode head) {
        if(head == null || head.next == null) return head;
        
        ListNode tmp = swapPairs(head.next.next);
        ListNode next = head.next;
        next.next = head;
        head.next = tmp;

        return next;
    }
}